package com.funong.matrix.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author : NaNa
 * @since : 2023-05-22 15:17
 **/
@Getter
@AllArgsConstructor
public enum DictType {
    /**
     * 字典值类型
     */
    STRING(1, "字符串String"),
    NUMBER(2, "数字Number");

    private Integer value;
    private String desc;

    public static DictType getByValue(Integer code) {
        return Arrays.stream(values())
                .filter(dictType -> Objects.equals(code, dictType.value))
                .findFirst()
                .orElse(STRING);
    }
}
